package com.nytd.demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@RequestMapping("/request")
@RestController
public class RequestController {

    @RequestMapping("/m1")
    public String age(int age) {
        return "接收参数age: " + age;
    }

    @RequestMapping("/m2")
    public String age(Integer age) {
        return "接收参数age: " + age;
    }

    @RequestMapping("/m3")
    public String name(String name) {
        return "接收参数name: " + name;
    }

    @RequestMapping("/m4")
    public String password(String password) {
        return "接收参数password: " + password;
    }

    @RequestMapping("/m5")
    public String register(String name, String password) {
        return "获取参数name: " + name + ", password: " + password;
    }

    @RequestMapping("/m6")
    public String register(Person person) {
        return "接收参数person: " + person;
    }

    @RequestMapping("/m7")
    public String register1(@RequestParam(value = "h", required = false) String name, @RequestParam("kkk") String password) {
        return "获取参数name: " + name + ", password: " + password;
    }

    @RequestMapping("/m8")
    public String arr(String[] arr) {
        return Arrays.toString(arr);
    }

    @RequestMapping("/m9")
    public String list(@RequestParam List<String> list) {
        return list.toString();
    }


}
